package framework.common;

/**
 * 実行モデルを生成する。
 * 将来的に実行モデル依存クラスは非推奨となり、隠ぺいされる。
 *
 * @author uehara
 *
 */
public class ModelFactory {
	public static final int SEQUENTIAL = 1;
	public static final int CONCURRENT = 1;
	public static final int DISTRIBUTED = 1;

	public static final int HUB_PORT = 4989;
	public static final int DEVICE_PORT = 4649;

	int model;

	public ModelFactory(int model) {
		this.model = model;
	}

	public ModelFactory() {
		this(SEQUENTIAL);
	}

	public HubServer getHubServer() {
		if (model == SEQUENTIAL)
			return new framework.sequential.HubServer();
		else if (model == CONCURRENT)
			return new framework.concurrent.HubServer();
		else if (model == DISTRIBUTED)
			return new framework.distributed.HubServer(HUB_PORT);
		return null;
	}

	public DeviceServer getDeviceServer(String name) {
		if (model == SEQUENTIAL)
			return new framework.sequential.DeviceServer(name);
		if (model == CONCURRENT)
			return new framework.concurrent.DeviceServer(name);
		if (model == DISTRIBUTED)
			return new framework.distributed.DeviceServer(name, DEVICE_PORT);
		return null;
	}

}
